import java.util.Scanner;

/**
 * <p>计算字符个数</p>
 *
 * @author: YuanChilde
 * @date: 2020-02-17 8:01
 * @version: 1.0
 * Modification History:
 * Date    Author      Version     Description
 * -----------------------------------------------------------------
 * 2020-02-17 8:01    YuanChilde     1.0        新增
 */
public class Demo2 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String line1 = sc.next().toUpperCase();
        char line2 = sc.next().toUpperCase().charAt(0);
        int count = 0;
        if (line1 != null && line1.length() > 0) {
            for (int i = 0; i < line1.length(); i++) {
                if (line1.charAt(i) == line2) {
                    count += 1;
                }
            }
        }
        System.out.println(count);
    }
}
